<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Web Solutions
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: vshoor $ ($Date: 2006/04/05 19:58:31 $)
// $RCSfile: impex.staff.php,v $ : $Revision: 1.3 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================

if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

/**
* Return the Total Pages for this Plugin
*/
function getPluginTotalPages4()
{
	return 1;
}

/**
* Run the specific page for plugin
*/
function runPluginPage4($page)
{
	global $impexDB, $_IMPEXHASH;

	$stafflist = array();
	$impexDB->query("SELECT * FROM `perlDesk_staff` ORDER BY `id` ASC;");
	while ($impexDB->nextRecord())
	{
		$stafflist[$impexDB->Record["id"]] = $impexDB->Record;
	}

	foreach ($stafflist as $oldstaffid=>$staff)
	{
		if ($staff["username"] == $_POST["username"]) // Same user as our current admin?
		{
			$staff["username"] = $staff["username"]."impex";
		}

		$_staffid = _impexInsertStaff($staff["name"], $staff["username"], md5($staff["username"]), iif($staff["access"]=="admin", "1", "2"), $staff["email"], "", $staff["signature"]);

		displayStatus("Imported Staff: ".htmlspecialchars($staff["username"]). " <b>Password same as Username</b>");

		$_IMPEXHASH["staffpointer"][$oldstaffid] = $_staffid;
		$_IMPEXHASH["staffuserpointer"][$staff["username"]] = array($_staffid, $staff["name"], $staff["email"]);
		$_IMPEXHASH["staffemailpointer"][$staff["email"]] = $_staffid;
		$_IMPEXHASH["staffdatapointer"][$oldstaffid] = array($_staffid, $staff["name"], $staff["email"]);
	}

	return true;
}
?>